package com.eight.vote.config;

import com.eight.vote.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>
 * //拦截器配置
 * </p>
 *
 * @author 点点星言
 * @since 2022-10-07
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenInterceptor())
                .excludePathPatterns(
                        //暂时先放行所有请求，方便测试
                       "/api/user/login",
                       "/api/user/reg",
                       "/api/vote/index/{pageNum}/{pageSize}",
                       "/api/vote/category/count",
                        "/api/vote/category/getAll"
                );

//        registry.addInterceptor(new UserInterceptor(redisTemplate)).order(0);
    }

}
